//
//  hyTableViewController.m
//  BaiSiBuDeJie
//
//  Created by uproject on 16/8/29.
//  Copyright © 2016年 tsaievan. All rights reserved.
//

#import "hyTableViewController.h"
#import "BSBaseModel.h"
#import "HyScrollViewModel.h"
#import "HyTableViewCell.h"

@interface hyTableViewController () <UITableViewDataSource,UITableViewDelegate>


@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property(nonatomic, strong) BSBaseModel  *baseModel;
@end

@implementation hyTableViewController
- (void)setHyModel:(HyScrollViewModel *)hyModel{
    _hyModel = hyModel;
    [BSBaseModel downDataWithUrl:hyModel.channel_url successBlock:^(BSBaseModel *model) {
        _baseModel = model;
        [self.tableView reloadData];
        
    } failBlock:^(NSError *err) {
        NSLog(@"%@",err);
    }];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.baseModel.list.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSArray *listArr = self.baseModel.list;
    HyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tableCell"];
    cell.model = listArr[indexPath.row];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 300;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
@end
